import {BlankLayout, BasicLayout, UserLayout, AppLayout} from "../layouts";
import {h, resolveComponent} from "vue";
import APP_ROUTES from "./app_routes";

// 基础布局下的路由
const BASIC_ROUTE = [
  {
    name: "org",
    // path: "/",
    component: BlankLayout,
    redirect: "/index",
    children: [
      // 子应用承载路由
      {
        name: "basic",
        path: "/",
        component: BlankLayout,
        children: [
          // 首页
          {
            path: "index",
            name: "home",
            component: () => import("@/views/home/workbench.vue"),
            meta: {title: "meta.homePage", keepAlive: false},
          },
          // 刷新中转页
          {
            path: "refresh",
            name: "refresh",
            component: () => import("@/views/refresh/index.vue"),
            meta: {title: "", keepAlive: false},
          },
          // 应用总览页面 { render: () => h(resolveComponent("router-view")) }, () => import("@/views/applications/index.vue"),
          {
            path: "applications",
            name: "applications",
            component: {render: () => h(resolveComponent("router-view"))},
            meta: {title: "应用中心", keepAlive: true, isIframe: true},
          },
          {
            path: "apps/:afterApps(.*)",
            name: "apps",
            component: () => import("@/views/apps/index.vue"),
            meta: {keepAlive: true},
          },
          {
            path: "iframes/:key",
            name: "iframes",
            component: () => import("@/views/iframes/index.vue"),
            meta: {keepAlive: true, IframePage: true},
          }
        ],
      },
      {
        name: "allComponents",
        path: "/allComponents",
        component: BlankLayout,
        children: [
          {
            path: "index",
            name: "allComponents",
            component: () => import("@/views/allComponents/index.vue"),
            meta: {title: "", keepAlive: false},
          },
          {
            path: "projectDetail",
            name: "ProjectDetailContent",
            component: () => import("@/views/allComponents/ProjectDetailContent/index.vue"),
            meta: {title: "", keepAlive: false},
          },
          {
            path: "billDetail",
            name: "billDetailContent",
            component: () => import("@/views/bill/BillDetail/index.vue"),
            meta: {title: "", keepAlive: false},
          },
          {
            path: "NewTenantsAdded",
            name: "NewTenantsAdded",
            component: () => import("@/views/village/OwnerManage/modules/NewTenantsAdded.vue"),
            meta: {title: "", keepAlive: false},
          },
          {
            path: "roomInfo",
            name: "roomInfo",
            component: () => import("@/views/allComponents/RoomInfo/index.vue"),
            meta: {title: "", keepAlive: false},
          },
          {
            path: "ownerDetail",
            name: "ownerDetailCom",
            component: () => import("@/views/allComponents/OwnerDetail/index.vue"),
            meta: {title: "", keepAlive: false},
          },
          {
            path: "contractDetail",
            name: "contractDetailCom",
            component: () => import("@/views/allComponents/ContractDetail/index.vue"),
            meta: {title: "", keepAlive: false},
          },
          {
            path: "billDetailCom",
            name: "billDetailCom",
            component: () => import("@/views/allComponents/BillDetail/index.vue"),
            meta: {title: "", keepAlive: false},
          },
        ],
      },
      ...APP_ROUTES,
    ],
  },
];

// 登录路由
const USER_ROUTE = [
  {
    name: "user",
    path: "/user",
    component: UserLayout,
    redirect: "/user/login",
    children: [
      // 登录页
      {
        path: "/user/login",
        name: "login",
        component: () => import("@/views/user/login.vue"),
        meta: {title: "meta.login", keepAlive: false},
      },
    ],
  },
];

// 不需要左侧菜单的自定义页面所有元素的路由
const CUSTOM_ROUTE = [
  {
    name: "main",
    path: "/main",
    component: BlankLayout,
    redirect: "/main/3d/layer",
    children: [
      // 楼层3d
      {
        path: "3d/layer",
        name: "layer3D",
        component: () => import("@/views/3D/Layer.vue"),
        meta: {title: "楼层3D"},
      },
      // 数据可视化
      {
        path: "dataVisualization/:type(.*)",
        name: "dataVisualization",
        component: () => import("@/views/DataV/index.vue"),
        meta: {title: "数据可视化"},
      },
    ],
  },
];

const AYSNC_ROUTES = [...BASIC_ROUTE, ...USER_ROUTE, ...CUSTOM_ROUTE];

export default AYSNC_ROUTES;
export {BASIC_ROUTE, USER_ROUTE, CUSTOM_ROUTE};
